package net.sasuke.firstapp;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sasuke.firstapp.vo.Employee;

public class SecondServlet extends HttpServlet {

   private static final long serialVersionUID = 1L;

   /*
    * (non-Javadoc)
    * 
    * @see
    * javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest
    * , javax.servlet.http.HttpServletResponse)
    */
   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse res)
         throws IOException, ServletException {
      String[] arr = { "sanjay", "rajiv", "hah" };
      req.setAttribute("arr", arr);
      req.setAttribute("zero", "zero");
      
      Employee e2 = new Employee();
      e2.setName("sanjay");
      e2.setDesignation("s/w engg");
      req.setAttribute("employee", e2);
      
      Employee e = new Employee();
      e.setName("sanjay-context");
      e.setDesignation("s/w engg-context");
      getServletContext().setAttribute("employee", e);
      
      NameBean bean = new NameBean();
      bean.setName("Sanjay-" + Math.random());
      req.setAttribute("nameBean", bean);
      req.getRequestDispatcher("/jsp/scriptless.jsp").forward(req, res);
   }

}